# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt

import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'


#%% FONCTION
kb = 1.4*10
N = 6
DeltaH0=40
T=2


def S(n): 
    return kb*T*(N*np.log(N)-(N-n)*np.log(N-n)-n*np.log(n))

def H(n):
    return DeltaH0*n

#LISTE DES X
nf = np.linspace(0.001,4,1000) #début, fin, nombre de points

#LISTE DES Y
Y1 = H(nf)
Y2 = S(nf)
Y3 = Y1 - Y2

#%% GRAPHE

fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111)

ax.set_xlim(0.001,4) #Limites de l'axe X
ax.set_ylim(-50,150) #Limites de l'axe Y

ax.set_xlabel(r'$n_F$', fontsize = 20) #Titre axe X
#ax.set_ylabel(r'$n_F$', fontsize = 20) #Titre axe Y


ax.plot(nf,Y1, label=r'$\Delta H$', lw=2) #label : nom dans la légende, lw : épaisseur du trait

ax.plot(nf,Y2, label=r'$T\Delta S$', lw=2) #label : nom dans la légende, lw : épaisseur du trait

ax.plot(nf,Y3, label=r'$\Delta G$', lw=4) 

#%% OPTIONNEL

#ax.grid(True) #Grille
ax.legend(loc=2 ,prop={'size':15}) #Legende


